﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace JVMTI_CORE_SHELL
{
    /// <summary>
    /// Interaction logic for QueryInterface.xaml
    /// </summary>
    public partial class QueryInterface : Window
    {
        public bool ApplyRequested { get; private set; }
        public bool ApplyClearSearch { get; private set; }

        public QueryInterface()
        {
            InitializeComponent();
        }

        QueryOptions options;

        public QueryInterface(QueryOptions options)
            : this()
        {
            rangeSlider.ValueChanged += rangeSlider_ValueChanged;
            this.options = options;
            this.DataContext = options;
        }

        void rangeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            double lowerTime = App.MinimumStartTime + (App.MaximumThreadEndTime - App.MinimumStartTime) * rangeSlider.LowerValue / 100;
            double upperTime = App.MinimumStartTime + (App.MaximumThreadEndTime - App.MinimumStartTime) * rangeSlider.UpperValue / 100;
            slicingInfo.Text = string.Format("search timestamps from {0} to {1}", lowerTime, upperTime).ToUpperInvariant();
        }

        private void WindowCloseButton_Click(object sender, RoutedEventArgs e)
        {
            ApplyRequested = false;
            this.Close();
        }

        private void apply_Click(object sender, RoutedEventArgs e)
        {
            ApplyRequested = true;
            this.Close();
        }

        private void clear_Click(object sender, RoutedEventArgs e)
        {
            ApplyClearSearch = true;
            this.Close();
        }


    }
}
